package com.cyzy.dto;

import java.io.Serializable;

public class ResponseDto  implements  Serializable  {

    private int code;
    private String message;
    private Object data;
    private int total; //总数

    public static ResponseDto ok(){
        return new ResponseDto(1,"success",null);
    }

    public static ResponseDto ok(Object data){
        return new ResponseDto(1,"success",data);
    }
    public static ResponseDto ok(Object data,int total)
    {
        return new ResponseDto(1,"success",data,total);

    }

    public static ResponseDto fail(){
        return new ResponseDto(-1,"failed",null);
    }
    public static ResponseDto fail(String message){
        return new ResponseDto(-1,message,null);
    }
    public ResponseDto() {
    }

    public ResponseDto(int code, String message, Object data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public ResponseDto(int code, String message, Object data, int total) {
        this.code = code;
        this.message = message;
        this.data = data;
        this.total = total;
    }

    public int getTotal() {
        return total;
    }

    public void setTotal(int total) {
        this.total = total;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    @Override
    public String toString() {
        return "ResponseDto{" +
                "code=" + code +
                ", message='" + message + '\'' +
                ", data=" + data +
                ", total=" + total +
                '}';
    }
}
